package com.travelsky.airchina.boarding.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.travelsky.airchina.boarding.dao.NewsDAO;
import com.travelsky.airchina.boarding.domain.News;
import com.travelsky.airchina.boarding.dto.NewsSearchCondition;
import com.travelsky.airchina.boarding.dto.NewsView;
import com.travelsky.airchina.boarding.service.NewsService;
import com.travelsky.airchina.boarding.util.PageUtil;

@Service("newsService")
public class NewsServiceImpl implements NewsService {
	@Autowired
	private NewsDAO newsDAO;
	public List<NewsView> findNewsPage(PageUtil pageUtil, NewsSearchCondition newsSearchCondition) {
		return newsDAO.findNewsPage(pageUtil, newsSearchCondition);
	}
	public void saveOrUpdateNews(News news) {
		newsDAO.makePersistent(news);
	}

	public News getNews(Long id) {
		return newsDAO.findById(id);
	}
	public int getNewsSum() {
		return newsDAO.getNewsSum();
	}
	public void deleteNews(Long id) {
		News entity =  newsDAO.findById(id);
		newsDAO.makeTransient(entity);
	}
	public boolean updateNewsStatus(Long id, String status) {
		return newsDAO.updateNewsStatus(id,status);
	}
	public List<News> getNewsListByNewsColumnCode(String newsColumnCode) {
		return newsDAO.getNewsListByNewsColumnCode(newsColumnCode);
	}
	public List<NewsView> findLastedNewsListByNewsColumnCode(
			String newsColumnCode, int sum) {
		return newsDAO.findLastedNewsListByNewsColumnCode(newsColumnCode,sum);
	}
	public List<NewsView> findLastedVideoListByNewsColumnCode(
			String newsColumnCode, int sum) {
		return newsDAO.findLastedVideoListByNewsColumnCode(newsColumnCode,sum);
	}
	public List<NewsView> findNewsPageByColumnId(PageUtil pageUtil,
			Long columnId) {
		return newsDAO.findNewsPageByColumnId(pageUtil,columnId);
	}
	public List<NewsView> findNewsPageByCondition(PageUtil pageUtil,
			NewsSearchCondition newsSearchCondition) {
		return newsDAO.findNewsPageByCondition(pageUtil,newsSearchCondition);
	}
	public List<NewsView> findNewsPageByColumnCode(PageUtil pageUtil,String columnCode) {
		return newsDAO.findNewsPageByColumnCode(pageUtil,columnCode);
	}
	public List<NewsView> findLastedVideoList(int sum) {
		return newsDAO.findLastedVideoList(sum);
	}
	public List<NewsView> findPictureNewsList(int sum) {
		return newsDAO.findPictureNewsList(sum);
	}

}
